package com.hh.servlet.edata;


import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.hh.dao.PingGuDao;

import java.io.IOException;

import static org.apache.commons.lang.math.NumberUtils.toInt;

@WebServlet("/PingGu")
public class PingGu extends HttpServlet {
    private static final long serialVersionUID = 1L;
    public PingGu() {
    }
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    	doPost(request,response);
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
        response.setHeader("content-type", "text/html;charset=UTF-8");
        /* 允许跨域的主机地址 */
        response.setHeader("Access-Control-Allow-Origin", "*");
        /* 允许跨域的请求方法GET, POST, HEAD 等 */
        response.setHeader("Access-Control-Allow-Methods", "*");
        /* 重新预检验跨域的缓存时间 (s) */
        response.setHeader("Access-Control-Max-Age", "3600");
        /* 允许跨域的请求头 */
        response.setHeader("Access-Control-Allow-Headers", "*");
        /* 是否携带cookie */
        response.setHeader("Access-Control-Allow-Credentials", "true");
        String key = request.getParameter("key");//搜索条件
        String pageSize = request.getParameter("pageSize");//前台点击的第几页
        String mzhm = request.getParameter("mzhm");
        PingGuDao pingGuDao = new PingGuDao();
        response.getWriter().print(pingGuDao.getPingGuList(key,pageSize,mzhm));
    }

}
